<!DOCTYPE html>
<html th:replace="layout :: layout(~{::title}, ~{}, ~{::script}, ~{::#heading}, ~{::#content}, 'project-save')"
      xmlns:th="http://www.thymeleaf.org">

<head>

    <title th:text="${form}?'修改项目':'添加项目'">编辑项目</title>

    <script th:src="@{{su}/common/js/jquery.form.js(su=${staticUrl})}"></script>
    <script>
        //保存数据
        function save() {
            var name = $("#name").val();
            if (name == '') {
                msgAlert("未输入项目名称")
                return false;
            }
            //定义参数
            var options = {
                url: $("#saveForm").attr("action"),
                dataType: "json",
                type: "post",
                success: function (re) {
                    if (re.status) {
                        location.href = $("#saveForm").attr("list-url");
                    }
                },
                error: function () {
                    msgAlert("操作失败")
                }
            };
            //jquery.form使用方式
            $("#saveForm").ajaxSubmit(options);
        }
    </script>

</head>

<body>
<div id="heading" class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2 th:text="${form}?'修改项目':'添加项目'">编辑项目</h2>
        <ol class="breadcrumb">
            <li class="breadcrumb-item">
                <a>项目管理</a>
            </li>
            <li class="breadcrumb-item active">
                <strong th:text="${form}?'修改项目':'添加项目'">编辑项目</strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">

    </div>
</div>
<div id="content" class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <form id="saveForm"
                          th:action="@{{su}/project/ajax/{type}(su=${staticUrl},type=${form}?'update':'add')}"
                          th:list-url="@{{su}/project/list(su=${staticUrl})}">
                        <input th:if="${form}" type="hidden" name="id" th:value="${form.id}">
                        <div class="hr-line-dashed"></div>
                        <div class="form-group  row"><label class="col-sm-2 col-form-label">项目名称</label>

                            <div class="col-sm-10"><input type="text" class="form-control" name="name" id="name"
                                                          th:value="${form}?${form.name}" autocomplete="off"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group  row"><label class="col-sm-2 col-form-label">ArtifactId</label>

                            <div class="col-sm-10"><input type="text" class="form-control" name="artifactId"
                                                          th:value="${form}?${form.artifactId}" autocomplete="off"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group  row"><label class="col-sm-2 col-form-label">Git</label>

                            <div class="col-sm-10"><select class="form-control m-b" name="git">
                                <option value="gitee" th:selected="${form}?${form.git}=='gitee'">码云</option>
                                <option value="github" th:selected="${form}?${form.git}=='github'">GitHub</option>
                            </select></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group  row"><label class="col-sm-2 col-form-label">吉祥物</label>

                            <div class="col-sm-10"><input type="text" class="form-control" name="mascot"
                                                          th:value="${form}?${form.mascot}" autocomplete="off"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group  row"><label class="col-sm-2 col-form-label">项目描述</label>

                            <div class="col-sm-10"><input type="text" class="form-control" name="desc"
                                                          th:value="${form}?${form.desc}" autocomplete="off"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group row">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-default btn-sm" type="button" onclick="history.go(-1)">返回</button>
                                <button class="btn btn-primary btn-sm" type="button" onclick="save()">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

</html>
